<?php
/**
 * Zobrazi pocet riadkov aplikacie
 * @author Tomas Srna
 * @package bakalarka
 */

echo "<pre>";

$out = "";

function linecount($dir)
{
	if(substr($dir, -3) == "doc") return 0;
	global $out;
	$linecount = 0;
	if ($handle = @opendir($dir)) {
	    while (false !== ($file = readdir($handle))) {
	        if ($file != "." && $file != "..") {
	        	$path = $dir.'/'.$file;
	        	if(substr($file, -3) == "php" || substr($file, -3) == "css" ||
	        	 substr($file, -2) == "js" || substr($file, -3) == "sql" ||
	        	 substr($file, -5) == "phtml") {
	        		$out .= $path.":".($lc=count(@file($path)))."\n";
	            	$linecount += $lc;
	        	}
	            $linecount += linecount($dir.'/'.$file);
	        }
	    }
	    closedir($handle);
	}
	
	return $linecount;
}

echo linecount('..');
echo "\n";
echo $out;

echo "</pre>";
